package locations;

import houseHold.House;

import java.util.ArrayList;

/**
 * Singleton
 * 
 * @author Minodor Keeps track of all locations/rooms in the scenario
 */
public class LocationArchive {
	private static LocationArchive instance = new LocationArchive();

	public static LocationArchive getInstance() {
		return instance;
	}

	public static void init() {
		for (int i = 0; i < House.getInstance().getRoomCount(); i++) {
			instance.archive.add(House.getInstance().getRoom(i).getName());
		}
	}

	private ArrayList<String> archive = new ArrayList<String>();

	private LocationArchive() {
		archive = new ArrayList<String>();
	}

	public void add(String location) {
		archive.add(location);
	}

	public int getCount() {
		return instance.archive.size();
	}

	public String getLocation(String name) {
		for (int index = 0; index < archive.size(); index++) {
			if (archive.get(index).equalsIgnoreCase(name))
				return archive.get(index);
		}
		return null;
	}
}